package service;

import entity.Car;
import entity.User;

import javax.jws.WebService;
import java.util.ArrayList;
import java.util.List;

/**
 * @author liujw
 * @create 2020/9/10 00:08
 */
@WebService(endpointInterface = "service.IUserService", serviceName = "userService")
//endpointInterface接口服务完整全类名
//serviceName服务名称
public class UserServiceImpl implements IUserService {
    //简单参数传递
    @Override
    public String sayHello(String name) {
        return "Hello," + name;
    }

    //复杂参数 传递
    @Override
    public List<Car> findCarsByUser(User user) {
        // 这里本应该查询数据库的，为了演示，做一些假数据
        if ("xiaoming".equals(user.getUsername())) {
            List<Car> cars = new ArrayList<Car>();
            Car car1 = new Car();
            car1.setId(1);
            car1.setCarName("大众途观");
            car1.setPrice(200000d);
            cars.add(car1);

            Car car2 = new Car();
            car2.setId(2);
            car2.setCarName("现代ix35");
            car2.setPrice(170000d);
            cars.add(car2);

            return cars;
        } else {
            return null;
        }
    }

    @Override
    public Car findOneCar(User user) {
        Car car = new Car();
        car.setId(3);
        car.setCarName("BMW");
        car.setPrice(300000d);
        return car;
    }
}

